﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Linq;

namespace HQPad.Models
{
    /// <summary>
    /// The results form a character import operation.
    /// </summary>
    public class CharacterImportResult
    {
        public bool Success { get; set; }
        public List<ImportMessage> Messages { get; set; }
        public XDocument CharacterXml { get; set; }

        public CharacterImportResult()
        {
            Success = false;
            Messages = new List<ImportMessage>();
        }

        /// <summary>
        /// Determine if there are any error messages.
        /// </summary>
        /// <returns>True if at least one error message.</returns>
        public bool AnyError()
        {
            return Messages.Any(m => m.IsError);
        }

        /// <summary>
        /// Determine if there are any warning messages.
        /// </summary>
        /// <returns>True if at least one warning message.</returns>
        public bool AnyWarnings()
        {
            return Messages.Any(m => m.IsWarning);
        }
    }

    public class ImportMessage
    {
        public string Message { get; set; }
        public bool IsWarning { get; set; }
        public bool IsError { get; set; }
    }

}